/*
 * Printer.h
 *
 *  Created on: 27/ott/2013
 *      Author: angelo
 */

#ifndef PRINTER_H_
#define PRINTER_H_

#include <stdio.h>
#include <stdlib.h>

#include "Coordinates.h"
#include "Survivor.h"
#include "Strip.h"
#include "StemIslands.h"
#include "SteinerNode.h"
#include "Config.h"
#include "EnvironmentArea.h"
#include "Grafo.h"

#define MAX_FILE_NAME 512

#define WIDTH_DIVISOR			25
#define HEIGHT_DIVISOR			50
#define HEIGHT_FONT_DIVISOR		2

#define NODE_HEIGHT		50
#define NODE_WIDTH		50

#define STEM_NODE_HEIGHT	50
#define STEM_NODE_WIDTH		50

class Printer {
public:
	static const char* COLOR_LIST_10[];

public:
	Printer(char *fileName_base, Config *conf);
	virtual ~Printer();

	void printOutRamdomMap(EnvironmentArea *ea);
	void printOutSurvivorsMap(EnvironmentArea *ea);

	void printOutStemIslands(StemIslands *si, EnvironmentArea *ea);

	void printOutStemIslands_GENERIC(StemIslands *si, EnvironmentArea *ea, int algo_idx);
	void printOutStemIslands_SCR(StemIslands *si, EnvironmentArea *ea);
	void printOutStemIslands_SCD(StemIslands *si, EnvironmentArea *ea);

	void printOutAllNodeAndSteiner(Grafo *g, int alg_idx);
	void printOutAllNodeAndOnlySteiner(Grafo *g, int alg_idx);

	void printOutFinalGraph(Grafo *g, int alg_idx);
	void printOutFinalGraphWithStem(Grafo *g, int alg_idx);

private:
	bool checkLogLevel(Config::LOG_LEVELS ll);

	void printOutStemIslands_BOTH(StemIslands *si, EnvironmentArea *ea, char *fname);

	void printOutStandardGraph(Grafo *g, char *filename);

	void recursivePrinting(FILE *file, Grafo *g, char *buff, int buffSize, list<int> &printedList);
	void recursiveStemPrinting(FILE *file, Grafo *g, char *buff, int buffSize, list<int> &printedList);

	map<int, int> colorList;
	map<int, int> colorListMAX10;

private:
	Config::LOG_LEVELS log_level;

	Config *configuration;

	char base_filename[MAX_FILE_NAME];
	char str_buff[MAX_FILE_NAME];

	int nChannels;
};

#endif /* PRINTER_H_ */
